<?php
/**
 * @author fyl
 * Date: 16-3-29 下午2:59
 */

class AdminService extends BaseService
{
    private static $self = NULL;

    static public function instance()
    {
        if (self::$self == NULL) {
            self::$self = new self;
        }
        return self::$self;
    }


    /**
     * 广告位添加
     * @param $paramObj
     * @return int
     */
    public function AdsAdd($paramObj)
    {
        if($paramObj->img1){
            $realPath = $paramObj->img1 -> getRealPath();
            if(filesize($realPath)>174080){
                QiniuUpload::instance()->image_png_size_add($realPath,$realPath);
            }
            $paramObj->img1 =  QiniuUpload::instance()->upload_files($paramObj->img1);

        }

        if($paramObj->img2){
            $realPath = $paramObj->img2 -> getRealPath();
            if(filesize($realPath)>174080){
                QiniuUpload::instance()->image_png_size_add($realPath,$realPath);
            }

            $paramObj->img2 =  QiniuUpload::instance()->upload_files($paramObj->img2);
        }

        if($paramObj->img3){
            $realPath = $paramObj->img3 -> getRealPath();
            if(filesize($realPath)>174080){
                QiniuUpload::instance()->image_png_size_add($realPath,$realPath);
            }
            $paramObj->img3 =  QiniuUpload::instance()->upload_files($paramObj->img3);
        }

       return $paramObj;
    }
}